package com.sunwayworld.basemodule.coredata.test.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.sunwayworld.framework.at.annotation.AuditTrailType;
import com.sunwayworld.framework.at.annotation.AuditTrailEntry;
import com.sunwayworld.framework.spring.annotation.GikamBean;

import com.sunwayworld.basemodule.coredata.test.dao.LimsTestMethodAnalyteDao;
import com.sunwayworld.basemodule.coredata.test.bean.LimsTestMethodAnalyteBean;
import com.sunwayworld.basemodule.coredata.test.service.LimsTestMethodAnalyteService;
import com.sunwayworld.framework.context.ApplicationContextHelper;
import com.sunwayworld.framework.restful.data.RestJsonWrapperBean;

@Repository
@GikamBean
public class LimsTestMethodAnalyteServiceImpl implements LimsTestMethodAnalyteService {

    @Autowired
    private LimsTestMethodAnalyteDao limsTestMethodAnalyteDao;

    @Override
    @SuppressWarnings("unchecked")
    public LimsTestMethodAnalyteDao getDao() {
        return limsTestMethodAnalyteDao;
    }

    @Override
    @Transactional
    @AuditTrailEntry(AuditTrailType.INSERT)
    public Long insert(RestJsonWrapperBean jsonWrapper) {
        LimsTestMethodAnalyteBean limsTestMethodAnalyte = jsonWrapper.parseUnique(LimsTestMethodAnalyteBean.class);
        limsTestMethodAnalyte.setId(ApplicationContextHelper.getNextIdentity());
        getDao().insert(limsTestMethodAnalyte);
        return limsTestMethodAnalyte.getId();
    }

}
